#!/usr/bin/env python3
# Created by han on 2016/6/21
import os, sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from module import public,maker


def school_main():
    while True:
        msg = "学校教导处"
        public.color_msg(33,msg,40,"*")
        frist = ["教师管理","课程管理","查看教师","查看课程"]
        user_chose = public.show(*frist)
        if not user_chose:
            break
        if user_chose == "1":
            while True:
                second = ["登记","注销"]
                user_chose = public.show(*second)#展示菜单
                if not user_chose:
                    break
                elif user_chose == "1":
                    teacher_name = maker.make_teacher()#创建老师对象
                    if not teacher_name:
                        msg = "已经有这个老师了"
                        public.color_msg(31, msg, 40)
                        continue
                    save_status = maker.save_teacher(teacher_name)#存储老师对象
                    if not save_status:
                        continue
                    else:
                        msg = "保存成功"
                        public.color_msg(32, msg, 40)
                elif user_chose == "2":
                    print("注销")     #注销老师时对应创建好的课程也要被删除
        elif user_chose == "2":#选课
            course_name = maker.make_course()   #创建课程完毕，
            maker.save_course(course_name)      #将选择好的课程对象写入文件
        elif user_chose == "3":#展示老师
            while True:
                tea_obj = maker.chose_teacher_obj()
                if not tea_obj:
                    break
                else:
                    maker.show_teacher(tea_obj)
                    break
        elif user_chose == "4":
            while True:
                course_obj = maker.chose_course_obj()
                if not course_obj:
                    break
                else:
                    maker.show_course(course_obj)
                    break
    #创建老师和课程已经ok，


school_main()